<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="root"></div>
</body>
<script>
    // 1- 创建一个XHR实例
    const xhr = new XMLHttpRequest();
    // 2- 指定请求方式,以及地址
    xhr.open("get","https://m.maizuo.com/gateway?cityId=110100&pageNum=1&pageSize=10&type=1&k=8206585");
    // 请求头
    xhr.setRequestHeader("X-Client-Info",'{"a":"3000","ch":"1002","v":"5.2.1","e":"17186151345962393859391489","bc":"110100"}');
    xhr.setRequestHeader("X-Host","mall.film-ticket.film.list")
    // 3- 发送
    xhr.send();
    xhr.responseType = "json";
    xhr.onload = function(){
        // 当得到响应体数据后执行
        // console.log(xhr.response.data.films);// 输出响应体
        const {films} = xhr.response.data;
        // 将数字1放到ID为root的元素中
        // document.querySelector("#root").innerHTML = 1;
        console.log(films)
        for(let i=0;i<films.length;i++){
            document.querySelector("#root").innerHTML += "<div>" +
                "<img height='200' src='"+films[i].poster +"'/>" +
                "<h3>"+films[i].name+"</h3><hr/>"+
                "</div>"
        }
    }
    
</script>
</html>